begintownscript;

variables;

int i,j,k,r1,choice;

body;

beginstate INIT_STATE;
        set_flag(3,1,0);
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
if (get_flag(3,0) < 8) {
        if (get_flag(3,1) < 10) {
                inc_flag(3,1,1);
                end();
        }
        if (get_flag(3,1) == 10) {
                print_str_color("The dark energy in this place drains you.",2);
                change_char_health(0,-40);
                change_char_energy(0,-10);
                change_char_health(1,-40);
                change_char_energy(1,-10);
                change_char_health(2,-40);
                change_char_energy(2,-10);
                change_char_health(3,-40);
                change_char_energy(3,-10);
                set_flag(3,1,0);
        }
}
break;

beginstate 10;
        reset_dialog_preset_options(2);
        choice = run_dialog(0);
        if (choice == 1)
                end();
        flip_terrain(15,29);
        flip_terrain(16,29);
        flip_terrain(15,33);
        flip_terrain(16,33);
        play_sound(106);
        play_sound(99);
        print_str_color("You hear the sounds of chains and grinding gears.",2);
break;

beginstate 11;
        reset_dialog_preset_options(3);
        choice = run_dialog(0);
        if (choice == 1)
                end();
        teleport_party(21,19,0);
break;

beginstate 12;
        if (get_flag(3,2) == 0) {
                reset_dialog();
                add_dialog_str(0,"This box has a mithral bar in it. Somehow, it didn't get dissolved when the wyrms took it.",0);
                add_dialog_choice(0,"Take.");
                add_dialog_choice(1,"Leave.");
                choice = run_dialog(1);
                }
        if (choice == 1) {
                set_flag(3,2,2);
                change_spec_item(2,1);
                end();
                }
        if (choice == 2)
                end();
break;

beginstate 13;
        if (get_flag(3,3) == 0) {
                reset_dialog();
                add_dialog_str(0,"You walk into the cave the hydras were guarding. This cave is absolutely black, and your lights fail to penetrate the darkness.",0);
                add_dialog_str(1,"There are a number of bodies near the entrance, from different species: human, nephil, and troglodyte.",0);
                add_dialog_str(2,"It seems that a number of different attempts were made to clean out the cave, all of which failed.",0);
                add_dialog_str(3,"You also sense that the cavern is filled with dark energy. Whatever's here, it's more than just hydras.",0);
                run_dialog(1);
                set_flag(3,3,1);
        }
break;